<?php
/**
 * 诊所申请管理
 * Created by PhpStorm.
 * User: dower
 * Date: 2016/7/26 0026
 * Time: 下午 15:31
 */
namespace Admin\Controller\Patient;

use Admin\Model\Patient\ClinicApplyModel;
use Admin\Controller\AdminController;
class ClinicApplyController extends AdminController{

    /**
     * 诊所申请列表
     */
    public function index()
    {
        //添加查询条件
        $where = array();
        //查询列表信息
        $applyModel = new ClinicApplyModel();
        $list = $applyModel->pageList($where);
        //记录用户当前页面
        $this->getAuth();
        $this->assign('list', $list['rows']);
        $this->assign('page',$list['pageHtml']);
        $this->display();
    }

    /**
     * 删除数据(真删除)
     * @param $id
     * @param string $file 数据库中的文件字段名,多个逗号分隔
     */
    public function remove($id,$file = '')
    {
        $applyModel = new ClinicApplyModel();
        $rst = $applyModel->remove($id,$file);
        if ($rst !== false) {
            $this->ajaxReturn(array('code' => 0));
        } else {
            $this->ajaxReturn(array('code' => 1, 'msg' => $applyModel->getError()));
        }
    }

    /**
     * 修改状态
     * @param $id
     * @param int $value
     */
    public function changeStatus($id,$value=1){
        $applyModel = new ClinicApplyModel();
        $rst = $applyModel->changeStatus($id,$value);
        if($rst===false){
            $this->ajaxReturn(array('code' => 1, 'msg' =>'修改状态失败'));
        }else{
            $this->ajaxReturn(array('code' => 0));
        }
    }

}